home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-06-28 | 656 b | 31 lines | [TEXT/CWIE] |
- // GraphicsDeviceObject.cp
-
- #ifndef GraphicsDeviceObject_h
- #include "GraphicsDeviceObject.h"
- #endif
- #ifndef ScreenLoop_h
- #include "ScreenLoop.h"
- #endif
-
- GDHandle GraphicsDeviceObject::Nearest( const Rectangle& target )
- {
- GDHandle nearest = 0;
- uint32 bestArea = 0;
- uint32 bestDistance = maxuint32;
-
- for ( ScreenLoop screen; screen.Unfinished(); screen++ )
- {
- uint32 area = ( target & (*screen).Bounds() ).Area();
- uint32 distance = target.TaxicabDistanceTo( (*screen).Bounds() );
-
- if ( area > bestArea || distance < bestDistance )
- {
- nearest = *screen;
- bestArea = area;
- bestDistance = distance;
- }
- }
-
- return nearest;
- }
-